package org.mercworks.knight.physics;

import org.odejava.GeomPlane;
import org.odejava.HashSpace;
import org.odejava.Odejava;
import org.odejava.World;
import org.odejava.collision.Contact;
import org.odejava.collision.JavaCollision;

public class KnightWorldPhysics
{
	private static World m_worldInstance;
	private static HashSpace m_collisionSpace;
	private static JavaCollision m_collisionCalcs;
	private static Contact m_contacts;

	public KnightWorldPhysics()
	{
		
	}
	
	public static void initKnightWorldPhysics()
	{
		Odejava.getInstance();
		m_worldInstance = new World();
		m_collisionSpace = new HashSpace();
		m_collisionCalcs = new JavaCollision(m_worldInstance);
		m_contacts = new Contact(m_collisionCalcs.getContactIntBuffer(), m_collisionCalcs.getContactFloatBuffer());
		
		m_worldInstance.setGravity(0.0f, -9.8f, 0.0f);
		m_worldInstance.setStepInteractions(10);
		m_worldInstance.setStepSize(.05f);

		m_collisionCalcs.setSurfaceMu(10.0f);
		
		//Body body = new Body(m_worldInstance);
		//GeomBox box = new GeomBox(500.0f, 100.0f, 500.0f);
		//body.addGeom(box);
		//box.setName("floor");
		//box.setPosition(-250.0f, -100.0f, 250.0f);
		//body.setGravityMode(0);
		
		GeomPlane plane = new GeomPlane(0, 5.0f, 0, 0);
		
		m_collisionSpace.addGeom(plane);
	}
	
	public static World getWorldInstance()
	{
		return m_worldInstance;
	}
	
	public static HashSpace getCollisionSpaceInstance()
	{
		return m_collisionSpace;
	}
	
	public static JavaCollision getCollisionCalcsInstance()
	{
		return m_collisionCalcs;
	}
	
	public static Contact getContactInstance()
	{
		return m_contacts;
	}
}
